package com.allenyuan.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JToolBar;
import javax.swing.JMenuBar;
import javax.swing.JButton;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.SwingConstants;
import javax.swing.JScrollPane;

public class PaintMainFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1879167574320380454L;

	private JPanel contentPane;
	
	public static final String LINE_ACTION_CMD = "line";
	public static final String CIRCLE_ACTION_CMD = "circle";
	public static final String IMAGE_ACTION_CMD = "image";
	public static final String BEZIER_ACTION_CMD = "bezier";
	public static final String TEXT_ACTION_CMD = "text";
	public static final String MOUSE_ACTION_CMD = "mouse";

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
					PaintMainFrame frame = new PaintMainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public PaintMainFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu menu = new JMenu("文件");
		menuBar.add(menu);
		
		JMenuItem menuItem = new JMenuItem("雕刻");
		menu.add(menuItem);
		
		JMenuItem menuItem_2 = new JMenuItem("设置");
		menu.add(menuItem_2);
		
		JMenuItem menuItem_1 = new JMenuItem("退出");
		menu.add(menuItem_1);
		
		JMenu menu_1 = new JMenu("帮助");
		menuBar.add(menu_1);
		
		JMenuItem menuItem_3 = new JMenuItem("关于");
		menu_1.add(menuItem_3);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{20, 0, 0};
		gbl_contentPane.rowHeights = new int[]{230, 0};
		gbl_contentPane.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		
		JToolBar toolBar = new JToolBar();
		toolBar.setFloatable(false);
		toolBar.setOrientation(SwingConstants.VERTICAL);
		GridBagConstraints gbc_toolBar = new GridBagConstraints();
		gbc_toolBar.anchor = GridBagConstraints.WEST;
		gbc_toolBar.insets = new Insets(0, 0, 0, 5);
		gbc_toolBar.fill = GridBagConstraints.VERTICAL;
		gbc_toolBar.gridx = 0;
		gbc_toolBar.gridy = 0;
		contentPane.add(toolBar, gbc_toolBar);
		
		PaintPane scrollPane = new PaintPane();
		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
		gbc_scrollPane.fill = GridBagConstraints.BOTH;
		gbc_scrollPane.gridx = 1;
		gbc_scrollPane.gridy = 0;
		contentPane.add(scrollPane, gbc_scrollPane);
		
		JButton mouseButton = new JButton("鼠标");
		mouseButton.setActionCommand(MOUSE_ACTION_CMD);
		mouseButton.addActionListener(scrollPane);
		toolBar.add(mouseButton);
		
		JButton lineButton = new JButton("直线");
		lineButton.setActionCommand(LINE_ACTION_CMD);
		lineButton.addActionListener(scrollPane);
		toolBar.add(lineButton);
		
		JButton circleButton = new JButton("圆");
		circleButton.setActionCommand(CIRCLE_ACTION_CMD);
		circleButton.addActionListener(scrollPane);
		toolBar.add(circleButton);
		
		JButton imageButton = new JButton("图片");
		imageButton.setActionCommand(IMAGE_ACTION_CMD);
		imageButton.addActionListener(scrollPane);
		toolBar.add(imageButton);
		
		JButton bezierButton = new JButton("曲线");
		bezierButton.setActionCommand(BEZIER_ACTION_CMD);
		bezierButton.addActionListener(scrollPane);
		toolBar.add(bezierButton);
		
		JButton textButton = new JButton("文字");
		textButton.setActionCommand(TEXT_ACTION_CMD);
		textButton.addActionListener(scrollPane);
		toolBar.add(textButton);
	}

}
